	<div class="popup" id="popup_uploadcontest_baiviet" style="display:none ;">
            <div class="popup_main" >
                <a class="close close_popup png" onclick="return close_Popup_Post_Contest();"><img src="<?php echo PATH_URL ?>static/images/btn_close2.png" class="png" alt="" /></a>
                <div><img src="<?=PATH_URL.'static/images/text_3.png'?>" alt="" class="png" /></div>
                <div class="dangbai_form mt20">
                    <div class="left">Chủ đề</div>
                    <div class="right">
                                <select name="category" id="category" style="width:100%;">
									<option value="0"> -- Chọn chủ đề -- </option>
									<?php 
									if(!empty($category)){
										foreach($category AS $c)
										{
									?>
										<option value="<?=$c->id?>" <?php if(isset($contesttmp[0]->category_id)){ if($contesttmp[0]->category_id == $c->id){ echo "selected = 'selected'";}} ?>><?=$c->name?></option>
									<?php 
										}
									}?>
								</select>
                    </div>
                    
                    <div class="clearAll"></div>
                </div>
                <div class="dangbai_form ">
                    <div class="left">Tiêu đề</div>
                    <div class="right"><input type="text" class="txt_dangbai" name="txt_title" id="txt_title" maxlength="100" value="<?php if(isset($contesttmp[0]->title)) { print $contesttmp[0]->title; }else{ print '';} ?>" /></div>
                    <div class="clearAll"></div>
                </div>
                <div class="dangbai_form">
                    <div class="left">Hình đại diện</div>
                    <div class="right" style="width: 560px;"><input type="text" class="txt_dangbai" id="image" style="width: 560px;" value="<?php if(isset($contesttmp[0]->file)) { print $contesttmp[0]->file; }else{ print '';} ?>"  /></div>
                    <div class="btn_chonanh" id="btn_chonanh">
                        <input type="button" id="btn_upload" value="" />
                        <input type="file" id="upload_file" class="upload_file_popup" name="upload_file"/>
                    </div>
                    <div class="clearAll"></div>
                </div>
                <div class="dangbai_form" style="height: 355px;">
                    <div class="left">Nội dung</div>
                    <div class="right" style="border: none;"><textarea id="content_baiviet_1" class="content_baiviet" name="txt_content" ><?php if(isset($contesttmp[0]->content)) { print $contesttmp[0]->content; }else{ print '';} ?></textarea></div>
                    <div class="clearAll"></div>
                </div>
                <div class="btn_dangbai" style="margin-left: 97px;"><a href="JavaScript:void(0);" onclick="return post_contest_baiviet();" class="btn_hoantat"></a><a href="JavaScript:void(0);" onclick="return post_contest_baiviet_tmp();" class="btn_xemtruocbaiviet"></a><a href="JavaScript:void(0);" class="btn_huy" onclick="return clear_content();"></a><div class="clearAll"></div></div>
                <div class="erorr" style="margin-left: 98px;margin-top: 10px;text-align: left;"></div>
                <div class="clearAll"></div>
            </div>
        </div>
        <script type="text/javascript">
         $(document).ready(function(){
            
            new AjaxUpload('btn_chonanh', {
                    action: '<?php echo site_url('contest/uploadavatar'); ?>', 
                    name: 'avatar',
                    onSubmit : function(file, ext){
                    },
                    onComplete: function(file, response){
                        if(response!=''){
                            $('#image').val(response);
                        }
                    }
                });
         });
        function xemtruoc_baiviet()
        {
       
                $("#popup_uploadcontest_baiviet").overlay().close();
                open_Popup();
                var url = root + 'contest/popup_baiviet_xemtruoc';
                $.post(url,{
                },
                function(data){
                    $('.popup_baiviet_xemtruoc').html(data);
                    $(".popup_xembaitruoc").overlay({
                    mask: {
                        color: '#000',
                        loadSpeed: 200,
                        opacity: 0.7
                    },
                    closeOnClick:false,
                    top: ($(window).height()-($('.popup_xembaitruoc').height())) / 2,
                    left:($(window).width()-($('.popup_xembaitruoc').width())) / 2,
                    onLoad: function(){
                        $('.js_content').jScrollPane();
                        var t = $.mask;
                        if(!t.isLoaded()){
                            t.load();
                            var ov = this.getOverlay();
                            ov.css('z-index', '10000');
                            
                        }
                    }
                });
                $(".popup_xembaitruoc").overlay().load();
                     
                });
        }
         function post_contest_baiviet_tmp()
            {
                up_2();
                var title =$("#txt_title").val();
                var content = $("#content_baiviet_1").val();
                var image = $('#image').val();
                if(title == "")
                {
                    $(".erorr").html('Bạn vui lòng nhập Tiêu đề .');
                    $("#txt_title").focus();
                    return false;
                }
                if(image == "")
                {
                    $(".erorr").html('Bạn vui lòng chọn hình ảnh.');
                    $("#image").focus();
                    return false;
                }
                if(content == "")
                {
                    $(".erorr").html('Bạn vui lòng nhập nội dung.');
                    $("#content_baiviet_1").focus();
                    return false;
                }
                var url ="<?= PATH_URL ?>contest/popup_contest_dangbaiviet_tmp";
                $.post(url,{
                    title:title,
                    content:content,
                    image:image
                },function(data){
                    if(data==1)
                    {
                      xemtruoc_baiviet();
                    }
                    if(data == 0)
                    {
         
                    }
                });
            }
        function post_contest_baiviet()
            {
                up_2();
                var title =$("#txt_title").val();
                var content = $("#content_baiviet_1").val();
                var image = $('#image').val();
                var category =  $('#category').val();
                if(category == 0)
                {
                    $(".erorr").html('Bạn vui lòng chọn chủ đề.');
                    $("#category").focus();
                    return false;
                }
                if(title == "")
                {
                    $(".erorr").html('Bạn vui lòng nhập Tiêu đề .');
                    $("#txt_title").focus();
                    return false;
                }
                if(image == "")
                {
                    $(".erorr").html('Bạn vui lòng chọn hình ảnh.');
                    $("#image").focus();
                    return false;
                }
                if(content == "")
                {
                    $(".erorr").html('Bạn vui lòng nhập nội dung.');
                    $("#content_baiviet_1").focus();
                    return false;
                }
                var url ="<?= PATH_URL ?>contest/popup_contest_dangbaiviet";
                $.post(url,{
                    title:title,
                    content:content,
                    image:image,
                    category : category
                },function(data){
                    if(data==1)
                    {
                        clear_content();
                        $("#popup_uploadcontest_baiviet").overlay().close();
                        open_Popup_thanhcong('contest');
                    }
                    if(data == 0)
                    {
         
                    }
                });
            }
            function clear_content()
            {
                $("#txt_title").val("");
                $("#content_baiviet_1").val("");
                $('#image').val("");
                CKEDITOR.instances.content_baiviet_1.setData('');
            }
            function up_2(){
                for ( instance in CKEDITOR.instances )
                    CKEDITOR.instances[instance].updateElement();
            }
        	var instance = CKEDITOR.instances['content_baiviet_1'];
            if (instance) { instance.destroy(true); }  
            CKEDITOR.docType = '<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.0 TransitionalEN">',  
            CKEDITOR.replace('content_baiviet_1',{height:270,width:668,resize_enabled:false, 
                scayt_autoStartup:false,disableNativeSpellChecker:false,skin:'kama',uiColor:'#fff',toolbar:[['Bold','Italic','Underline','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','Anchor','Image','Flash','Tabale','Smiley','-','Scayt','-','NumberedList','BulletedList','-','Cut','Copy','Paste','PasteText','PasteFromWord','-']]});
			
        </script>